/* Y o u r   D e s c r i p t i o n                       */
/*                            AppBuilder Photon Code Lib */
/*                                         Version 2.01  */

/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"


int
hotkey ( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PhKeyEvent_t *KeyEvent;
	int page;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	if (cbinfo->event->type == Ph_EV_KEY) {
		page = -1;
		KeyEvent = PhGetData (cbinfo -> event);
		switch (KeyEvent -> key_sym)  {
			case 0xf0be: // F1
				page = 0;
				break;
			case 0xf0bf: // F2
				page = 1;
				break;
			case 0xf0c0: // F3
				page = 2;
				break;
			case 0xf0c1: // F4
				page = 3;
				PtSetResource (ABW_PtPanelGroup2, Pt_ARG_PG_CURRENT_INDEX, 0, 0);
				break;
			case 0xf0c2: // F5
				page = 4;
				PtGiveFocus (ABW_PtSchemeGroup, NULL);
				break;
			case 0xf0c3: // F6
				page = 5;
				PtSetResource (ABW_PtPanelGroup3, Pt_ARG_PG_CURRENT_INDEX, 0, 0);
				break;
			case 0xf0c9: // F12
				if (KeyEvent->key_mods & Pk_KM_Ctrl)
					exit (EXIT_FAILURE);
				break;
		}
	
		if (page != -1) {
			PtSetResource (ABW_PtPanelGroup1, Pt_ARG_PG_CURRENT_INDEX, page, 0);
		}
	}

	return( Pt_CONTINUE );

}

